import React from 'react'
import { Badge, TabBar } from 'antd-mobile'
import {
    AppOutline,
    MessageOutline,
    MessageFill,
    UnorderedListOutline,
    UserOutline,
} from 'antd-mobile-icons'
import { useNavigate } from 'react-router-dom'
import styles from './css/Mytabbar.module.css'

function Mytabbar() {
    const nav = useNavigate()
    const tabs = [
        {
            key: 'index',
            title: '首页',
            icon: <AppOutline />,
            badge: Badge.dot,
        },
        {
            key: 'message',
            title: '待办',
            icon: <UnorderedListOutline />,
            badge: '5',
        },
        {
            key: 'order',
            title: '消息',
            icon: (active) =>
                active ? <MessageFill /> : <MessageOutline />,
            badge: '99+',
        },
        {
            key: 'my',
            title: '我的',
            icon: <UserOutline />,
        },
    ]
    const onchange = (key) => {
        nav(key)
    }
    return (
        <div className={styles.box}>
            <TabBar onChange={onchange}>
                {tabs.map(item => (
                    <TabBar.Item key={item.key} icon={item.icon} title={item.title} />
                ))}
            </TabBar>
        </div>
    )
}

export default Mytabbar
